Central Article

Creating Your First Macromedia Central Application


Table of Contents

  1. Introduction
  2. Structure and Terms Before Getting Started
  3. Creating a Simple Central Application
  4. Updating Your Central Application
  5. Creating an Agent
  6. Turning a Simple Application into Something Useful

Updating Your Central Application

Whether you add features or fix bugs, you'll want to test the results inside Central. However, you don't have to uninstall and reinstall your application every time you make a change. Instead, you can "update" the version number of your application (which notifies users that a newer version is available for installation) or "overwrite" it, which means just manually writing over the cached files in your Central directory.

I cover overwriting later because it's more of a production tip. In addition, overwriting only works when the list of product files doesn't change. Below I show you how to add a pod to your product. To install the new files, just change the version number in product.xml.

  1. Create a new file, just as you did in the previous section (publish settings to Flash Player 6, uncheck the HTML format, and add a TextArea instance named ta). In this case, use the following code:

    #include "pod.as"

  2. Change the document properties (press Ctrl-J) to 170 x 160 pixels.
  3. Save this file as pod.fla.
  4. Create a new ActionScript file with Flash MX Professional 2004 and save the file as pod.as, adjacent to pod.fla.
  5. Type the following code:

    onActivate = function(console, podID, viewerID, position, baseTabIndex, data) {
      gShell=console;
      var myString="";
      myString += "console=" +      console      +newline;
      myString += "podID=" +        podID        +newline; 
      myString += "viewerID=" +     viewerID     +newline;
      myString += "position=" +     position     +newline;
      myString += "baseTabIndex=" + baseTabIndex +newline;
      myString += "appData=" +      appData;
      ta.text = myString;
    }
    Central.initPod(this, this);

    This code should look familiar. The only difference from the app.as file you created earlier is that you initialize with initPod(), not initApplication(), and the parameters received include position, an integer that matches the slot into which your pod appears. All new pods appear in the zero slot (the uppermost position) but get pushed down as newer ones appear or as the user rearranges them.

    You're still saving a reference to the window that holds this application—although in this case, it's the Console that hosts the pod, not the shell hosting an application. It's still the first parameter received, however. I use gShell again just as a matter of convention. Later in the application you can use gShell to access anything in the Console object (say, gShell.loadApplication() to launch the application portion of this product).

  6. Save pod.as, return to pod.fla, and publish pod.swf (press Shift-F12).
  7. Open product.xml to add the pod and increment the version number. Specifically, change this line:

    version="1.0"

    so it reads:

    version="1.1"

    Also change this line:

    <!--<pod name="Sample Pod" src="pod.swf" height="160"/>-->

    so it reads:

    <pod name="Sample Pod" src="pod.swf" height="160"/>

  8. Save product.xml.
  9. Place pod.swf adjacent to product.xml and the rest of your product files—that is, the same location from which you installed the application earlier.
  10. Quit and relaunch Central and open the application. Select Check for Update from the My First App menu and click OK in the dialog box that appears (shown in Figure 3). When complete, choose View > Console and select My First App from the Pods menu in the Console to see your new pod.
After checking for updates, Central gives you the opportunity to upgrade the application.

Figure 3. After checking for updates, Central gives you the opportunity to upgrade the application.

Note: If you have problems with this portion, the completed files are in the folder "part2_finished--Updating Your Central Application."

Making a pod is not much different than making a regular application. Naturally, it's a smaller version of it. Any single application can have several pods. (Additional pods appear in a secondary drop-down list within the pod because your application only appears once in the Console.)

In addition to showing the similarities between pods and applications, this exercise demonstrates how easily you can update your application. There is no need to reinstall it; you just update it. As you work you may not even want to go through this simple process for every little change. In that case, you can just change the publish destination in Flash (see Figure 4) so that exported SWFs overwrite the files in Central's cache. This works only for files that are already present. In the exercise above you adjusted product.xml to include the pod. Now that the pod is part of your installed application you can update the pod by simply overwriting it. Naturally, you have to close and reopen your application or pod to see the changes appear.

By changing the target publish folder in Flash you can update your application files while testing. Just point to the cache folder in Central.

Figure 4. By changing the target publish folder in Flash you can update your application files while testing. Just point to the cache folder in Central.

Incidentally, you can overwrite agents too. However, because agents won't stop running when you switch applications, you need to restart Central for your changes to the agent to become noticeable. I cover agents next.